﻿using System;
using System.ServiceModel;
using System.Windows;
namespace LanSunStudio.Service.RTIService
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        ServiceHost host;
        public MainWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
            this.Unloaded += new RoutedEventHandler(MainWindow_Unloaded);
        }

        void MainWindow_Unloaded(object sender, RoutedEventArgs e)
        {
            if (host != null)
                host.Close();
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        { 
            try
            {
                log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 
                // The service configuration is loaded from app.config
                host = new ServiceHost(typeof(RTIService));
                host.Open();               
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.Source + ex.StackTrace);
            } 
        }
    }
}
